package com.xx.dao;


import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import com.xx.entity.Atmessage;
import com.xx.entity.Employee;
import com.xx.util.DBHelp;
import com.xx.util.RowMapper;

public class AtmessageDao {
DBHelp<Atmessage > dbHelp= new DBHelp<Atmessage>();
public void insertAtmessage(Atmessage atmessage,Employee semp){
	String sql="insert into t_atmessage(t_message_id,t_employee_id,t_project_id) value(?,?,?),(?,?,?)";
	dbHelp.executeSQL(sql,atmessage.getMessageid(),atmessage.getEmployeeid(),atmessage.getProjectid(),atmessage.getMessageid(),semp.getId(),atmessage.getProjectid());
	
}

public List<Atmessage > findAtmessages(){
	
	String sql="select t_message_id,t_employee_id,t_project_id  from t_atmessage ";
	return dbHelp.executeQueryForList(sql, new AtmessageMapper());
	
}
	public class AtmessageMapper implements RowMapper<Atmessage>{

		public Atmessage mapperRow(ResultSet rs) throws SQLException {
			Atmessage atmessage=new Atmessage();
			atmessage.setEmployeeid(rs.getString("t_employee_id"));
			atmessage.setMessageid(rs.getString("t_message_id"));
			atmessage.setProjectid(rs.getString("t_project_id"));
			return atmessage;
		}
		
	}
	
}
